package com.lsh.oms.core.dao.other;

import com.lsh.oms.core.dao.MyBatisRepository;
import com.lsh.oms.core.model.order.OrderShippingHead;
import com.lsh.oms.core.model.order.OrderSignHead;
import com.lsh.oms.core.records.ReturnRequestRecord;
import com.lsh.oms.core.records.core.ReturnRequest;
import com.lsh.oms.core.service.tool.Criteria;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@MyBatisRepository
public interface ReturnRequestMapper {

    void insert(@Param("request") Map<String, Object> request,
                @Param("shipping") OrderShippingHead shipping,
                @Param("receipt") OrderSignHead receipt);

    void insertDetails(@Param("request") Map<String, Object> request);

    ReturnRequestRecord findById(@Param("id") Long id);

    ReturnRequest.ReturnRequestDetail findDetailById(@Param("id") Long id);

    List<ReturnRequestRecord> findBaseOnCriteria(@Param("criteria") Criteria criteria, @Param("start") long start, @Param("limit") long limit);

    Long countBaseOnCriteria(@Param("criteria") Criteria criteria);

    List<ReturnRequestRecord.ReturnRequestDetailRecord> findDetails(@Param("return_request_ids") Collection<Long> returnIds);

    List<ReturnRequestRecord.ReturnRequestDetailRecord> totalApplied(@Param("order_id") Long order_id);

    List<Map<String, Object>> groupByStatus(@Param("criteria") Criteria criteria);

    int updateDetail(@Param("request") Map<String, Object> request);

    int update(@Param("return_request") ReturnRequest returnRequest,
               @Param("request") Map<String, Object> request,
               @Param("base_status") ReturnRequest.Status status);

    int updateRefundNotifyRequest(@Param("refund_notify_request") Map<String, Object> request,
                                  @Param("id") Long id);

    int updateDetailDeliveredQuantity(@Param("return_request_id") Long returnRequestId,
                                      @Param("item_code") Integer itemCode,
                                      @Param("quantity") BigDecimal quantity);

}